package com.cfpamf.ms.insur.pay.pojo.convert;

import com.alipay.api.response.AlipayTradeQueryResponse;
import com.cfpamf.ms.insur.pay.facade.dto.PayOrderNotifyDTO;
import com.cfpamf.ms.insur.pay.facade.dto.PreCreateOrderDTO;
import com.cfpamf.ms.insur.pay.facade.vo.QueryOrderVO;
import com.cfpamf.ms.insur.pay.integration.dto.BankPreCreateOrderParamDTO;
import com.cfpamf.ms.insur.pay.integration.dto.BankQueryOrderRetDTO;
import com.cfpamf.ms.insur.pay.integration.dto.BankQueryRefundRetDTO;
import com.cfpamf.ms.insur.pay.pojo.po.PayOrderPO;
import com.cfpamf.ms.insur.pay.pojo.po.PayOrderTrxPO;
import com.cfpamf.ms.insur.pay.pojo.po.PayRefundPO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @author zhangnayi
 */
@Mapper
public interface PayOrderConvert {

    PayOrderConvert CONVERT = Mappers.getMapper(PayOrderConvert.class);

    @Mappings({
            @Mapping(source = "productId", target = "productId"),
            @Mapping(source = "productName", target = "productName"),
            @Mapping(source = "productType", target = "productType"),
            @Mapping(source = "userNo", target = "userNo"),
            @Mapping(source = "payType", target = "payType"),
            @Mapping(source = "payMethod", target = "payMethod"),
            @Mapping(source = "sourceOrderId", target = "sourceOrderId"),
            @Mapping(source = "sourceSys", target = "sourceSys"),
            @Mapping(source = "notifyUrl", target = "notifyUrl"),
            @Mapping(source = "returnUrl", target = "returnUrl")
    })
    PayOrderPO preCreateOrder2PayOrder(PreCreateOrderDTO dto);

    @Mappings({
            @Mapping(source = "sourceSys", target = "sourceSys"),
            @Mapping(source = "payType", target = "payType"),
            @Mapping(source = "payMethod", target = "payMethod"),
            @Mapping(source = "orderAmount", target = "orderAmount"),
            @Mapping(source = "orderTime", target = "orderTime")
    })
    PayOrderTrxPO preCreateOrder2PayOrderTrx(PreCreateOrderDTO paramDTO);

    @Mappings({
            @Mapping(source = "sourceSys", target = "sourceSys"),
            @Mapping(source = "productName", target = "productName"),
            @Mapping(source = "payMethod", target = "payMethod"),
            @Mapping(source = "orderAmount", target = "orderAmount"),
            @Mapping(source = "orderPeriod", target = "orderPeriod"),
            @Mapping(source = "returnUrl", target = "returnUrl")
    })
    BankPreCreateOrderParamDTO preCreateOrderDTO2BankPreCreateOrderParamDTO(PreCreateOrderDTO dto);

    @Mappings({
            @Mapping(source = "sourceOrderId", target = "sourceOrderId"),
            @Mapping(source = "sourceSys", target = "sourceSys"),
            @Mapping(source = "orderNo", target = "orderNo"),
            @Mapping(source = "productId", target = "productId"),
            @Mapping(source = "productName", target = "productName"),
            @Mapping(source = "productType", target = "productType"),
            @Mapping(source = "payType", target = "payType"),
            @Mapping(source = "payMethod", target = "payMethod"),
            @Mapping(source = "payTrxNo", target = "payTrxNo"),
            @Mapping(source = "bankPayTrxNo", target = "bankPayTrxNo"),
            @Mapping(source = "orderAmount", target = "orderAmount"),
            @Mapping(source = "orderTime", target = "orderTime"),
            @Mapping(source = "payTime", target = "payTime"),
            @Mapping(source = "refundAmount", target = "refundAmount"),
            @Mapping(source = "payStatus", target = "payStatus")
    })
    QueryOrderVO payOrder2QueryOrderRetDTO(PayOrderPO payOrder);

    @Mappings({
            @Mapping(source = "sourceOrderId", target = "sourceOrderId"),
            @Mapping(source = "sourceSys", target = "sourceSys"),
            @Mapping(source = "orderNo", target = "orderNo"),
            @Mapping(source = "orderAmount", target = "orderAmount"),
            @Mapping(source = "refundAmount", target = "refundAmount"),
            @Mapping(source = "payStatus", target = "payStatus")
    })
    PayOrderNotifyDTO payOrderPO2PayOrderNotifyDTO(PayOrderPO entity);

    @Mappings({
            @Mapping(source = "outTradeNo", target = "payTrxNo"),
            @Mapping(source = "tradeNo", target = "bankPayTrxNo"),
            @Mapping(source = "totalAmount", target = "orderAmount"),
            @Mapping(source = "sendPayDate", target = "payTime")
    })
    BankQueryOrderRetDTO alipayTradeQueryResponse2QueryOrderRetDTO(AlipayTradeQueryResponse queryResp);

    @Mappings({
            @Mapping(source = "payTrxNo", target = "payTrxNo"),
            @Mapping(source = "bankPayTrxNo", target = "bankPayTrxNo"),
            @Mapping(source = "payTime", target = "payTime"),
            @Mapping(source = "payStatus", target = "payStatus")
    })
    PayOrderPO bankQueryOrderRetDTO2PayOrderPO(BankQueryOrderRetDTO dto);

    @Mappings({
            @Mapping(source = "payTrxNo", target = "payTrxNo"),
            @Mapping(source = "bankPayTrxNo", target = "bankPayTrxNo"),
            @Mapping(source = "payTime", target = "payTime"),
            @Mapping(source = "payStatus", target = "payStatus")
    })
    PayOrderTrxPO bankQueryOrderRetDTO2PayOrderTrxPO(BankQueryOrderRetDTO dto);

    @Mappings({
            @Mapping(source = "refundStatus", target = "refundStatus"),
            @Mapping(source = "refundAmount", target = "refundAmount"),
            @Mapping(source = "bankRefundTrxNo", target = "bankRefundTrxNo"),
            @Mapping(source = "refundTime", target = "refundCompleteTime")
    })
    PayRefundPO bankQueryRefundRetDTO2PayRefundPO(BankQueryRefundRetDTO dto);
}
